package proj1.constants;

import java.util.Comparator;

import proj1.dao.Make;
import proj1.dao.Model;
import proj1.dao.Radiator;
import proj1.dao.Vendor;

public class C {
	// These exit statuses are totally arbitrary
	public static final class EXIT_STATUS{
		/** Unspecified fatal error. Exit code: {@value} */
		public static final int FATAL = 2;
		/** Configuration error. Exit code: {@value} */
		public static final int INVALID_CONFIGURATION = 3;
	}
	
	public static final class TABLE_PREFIX{
		public static final String MODEL = "APL";
		public static final String RADIATOR = "RAD";
	}
	
	public static final class COMPARATOR{
		
		public static final Comparator<Make> MAKE = new Comparator<Make>(){
			// Sort Make results by make name alphabetically
			@Override
			public int compare(Make mak0, Make mak1) {
				return mak0.getMake().compareTo(mak1.getMake());
			}
		};

		public static final Comparator<Model> MODEL = new Comparator<Model>(){
			// Sort by name, then year, then description
			@Override
			public int compare(Model model0, Model model1){
				int result = model0.getModel().compareTo(model1.getModel());
				if(result == 0)
					result = model0.getYear().compareTo(model1.getYear());
				
				if(result == 0)
					result = model0.getDescription().compareTo(model1.getDescription());
				
				return result;
			}
		};

		public static final Comparator<Radiator> RADIATOR = new Comparator<Radiator>(){
			// Sort by part number
			@Override
			public int compare(Radiator rad0, Radiator rad1){
				return rad0.getPartNumber().compareTo(rad1.getPartNumber());
			}
		};

		public static final Comparator<Vendor> VENDOR = new Comparator<Vendor>(){
			// Sort by name
			@Override
			public int compare(Vendor ven0, Vendor ven1){
				return ven0.name().compareTo(ven1.name());
			}
		};
	}
}
